package com.crm.controller;


import com.crm.constant.dto.BaseFxResponse;
import com.crm.entity.CrmEmployee;
import com.crm.entity.CrmSite;
import com.crm.model.bo.CrmSitePageBo;
import com.crm.model.bo.EmployeePageBo;
import com.crm.model.dto.BasePageResult;
import com.crm.model.vo.EmployeeVo;
import com.crm.service.ICrmSiteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * CRM-场地表 前端控制器
 * </p>
 *
 * @author CRM_SYSTEM
 * @since 2022-03-30
 */
@RestController
@RequestMapping("/crm-site")
@Slf4j
public class CrmSiteController {

    @Autowired
    private ICrmSiteService siteService;

    @RequestMapping(value = "/queryById", method = RequestMethod.GET)
    public BaseFxResponse<CrmSite> queryById(@RequestParam("siteId") Long siteId) {
        return BaseFxResponse.success(siteService.queryById(siteId));
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public BaseFxResponse<Long> saveSite(@RequestBody @Validated CrmSite crmSite) {
        log.info("save crmSite={}",crmSite);
        return BaseFxResponse.success(siteService.saveSite(crmSite));
    }
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseFxResponse<Long> updateSite(@RequestBody @Validated CrmSite crmSite) {
        return BaseFxResponse.success(siteService.updateSite(crmSite));
    }

    @RequestMapping(value = "/query/page",method = RequestMethod.POST)
    public BaseFxResponse<BasePageResult<CrmSite>> queryPage(@RequestBody @Validated CrmSitePageBo sitePageBo){
        return BaseFxResponse.success( siteService.queryPage(sitePageBo));
    }

    @RequestMapping(value = "/deleteById", method = RequestMethod.GET)
    public BaseFxResponse<Boolean> deleteById(@RequestParam("siteId") Long siteId) {
        return siteService.deleteById(siteId);
    }

}

